let express = require('express')
let home = require('./api/home')

const app = express()

// 设置跨域
app.use(function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*')
  res.header(
    'Access-Control-Allow-Headers',
    'Content-Type,Content-Length,Authorization,Accept,X-Requested-With,yourHeaderFeild',
  )
  res.header('Access-Control-Allow-Methods', 'PUT,GET,POST,DELETE,OPTIONS')
  next()
})

// 中间件配置路由
// 这里的api是前缀
app.use('/api', home)

app.listen(8888)
